package com.jiuyin.dianjing.ui.activity.team;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;

import com.jiuyin.dianjing.R;
import com.jiuyin.dianjing.ui.activity.base.BaseActivity;
import com.jiuyin.dianjing.ui.fragment.team.TeamsFragment;

import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_TYPE;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_USERID;

/**
 * 全部战队
 */
public class MyTeamsActivity extends BaseActivity {

    private String type;
    private String mUserId = "";

    @Override
    protected int setLayoutId() {
        return R.layout.activity_my_teams;
    }

    @Override
    protected void initData() {
        setTitle(getString(R.string.team_list));
        update();
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
        update();
    }

    @Override
    protected void initView() {

    }

    private void update() {
        Bundle bundle = getIntent().getExtras();
        if (null != bundle) {
            type = bundle.getString(KEY_TYPE);
            mUserId = bundle.getString(KEY_USERID);
        }
        if (!TextUtils.isEmpty(type)) {
            if (!type.equals("2")) {
                setRightButton(R.drawable.tianjia, v -> {
                    goTargetActivity(ChooseActivity.class);
                });
            }
        }
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.layout_fragment, TeamsFragment.newInstance("", mUserId, true))
                .commit();
    }
}
